예제 #1
0
        public bool Delete(mo.EnterpriseClient EnterpriseClient)
        {
            var result = false;

            try
            {
                if (EnterpriseClient == null)
                {
                    throw new ArgumentNullException("EnterpriseClient");
                }

                _enterpriseClientRepo.Delete(EnterpriseClient);

                result = true;
            }
            catch
            {
                throw;
            }

            return(result);
        }
예제 #2
0
        public bool Update(mo.EnterpriseClient EnterpriseClient)
        {
            var result = false;

            try
            {
                if (EnterpriseClient == null)
                {
                    throw new ArgumentNullException("EnterpriseClient");
                }

                EnterpriseClient.ModificationTime = DateTime.UtcNow;

                _enterpriseClientRepo.Update(EnterpriseClient);

                result = true;
            }
            catch
            {
                throw;
            }

            return(result);
        }
예제 #3
0
        public IActionResult Add([FromBody] dynamic value)
        {
            var name = "";

            try
            {
                string svalue = Convert.ToString(value);

                dynamic EnterpriseClientJsonEntity = JsonConvert.DeserializeObject(svalue);

                name = EnterpriseClientJsonEntity["name"].Value;

                var location = EnterpriseClientJsonEntity["location"].Value;

                var partnerId = EnterpriseClientJsonEntity["pid"].Value;


                var newObj = new ent.manager.Entity.Model.EnterpriseClient()
                {
                    Name = name, Location = location, PartnerId = Convert.ToInt32(partnerId)
                };

                var result = _enterpriseClientService.Add(newObj);


                if (result)
                {
                    if (!_eKeyService.Save(newObj.Id))
                    {
                        return(Json(new
                        {
                            c = ResultCode.EnterpriseResultCodes.EkeyFailedToAdd,
                            d = ""
                        }));
                    }

                    return(Json(new
                    {
                        c = ResultCode.Success,
                        d = ""
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        c = ResultCode.EnterpriseResultCodes.EnterpriseFailedToAdd,
                        d = ""
                    }));
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.GetLogText("ec_add"));

                var enterprse = _enterpriseClientService.GetByName(name);

                if (enterprse != null)
                {
                    return(Json(new
                    {
                        c = ResultCode.EnterpriseResultCodes.EnterpriseNameAlreadyExists,
                        d = ex.Message
                    }));
                }



                return(Json(new
                {
                    c = ResultCode.GenericException,
                    d = ex.Message
                }));
            }
        }