コード例 #1
0
        public async Task <IActionResult> PostBlogPost([FromBody] BlogPost blogPost)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _logger.LogInformation(LoggingEvents.CreateBlogPost, "Creating BlogPost from Creator: {0}", blogPost.Creator);

            _repo.Add(blogPost);
            await _repo.SaveAsync(blogPost);

            return(CreatedAtAction("GetBlogPost", new { id = blogPost.PostId }, blogPost));
        }
コード例 #2
0
 /// <summary>
 /// This method used for insert into pos bill payment . -An
 /// </summary>
 /// <param name="posSession">POSLoginSessionId,MismatchResolveTypeID,StartDate,EndDate,IsMatched,MismatchedValue,Cash,DebitCard,CreditCard,Coupon,CreditAccount,ReturnedBill,ActualCash,ActualDebitCard,ActualCreditCard,ActualCoupon,ActualCreditAccount,ActualReturnedBill</param>
 /// <returns></returns>
 public int InsertPOSSessionsData(POSSession posSession)
 {
     try
     {
         _posSessionContext.Add(posSession);
         _posSessionContext.SaveChanges();
         return(posSession.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #3
0
 /// <summary>
 /// This method used for add destruction object. -An
 /// </summary>
 /// <param name="destruction"></param>
 /// <returns></returns>
 public Destruction AddDestruction(Destruction destruction)
 {
     try
     {
         _iDestructionContext.Add(destruction);
         _iDestructionContext.SaveChanges();
         return(destruction);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #4
0
ファイル: LoginService.cs プロジェクト: hridayN/TicketSystem
        /// <summary>
        /// Creates new agent in DB
        /// </summary>
        /// <param name="email">email of customer</param>
        /// <returns></returns>
        private Agent CreateAgent()
        {
            AgentEntity newAgent = _agentRepository.Add(new AgentEntity()
            {
                AgentId   = Guid.NewGuid(),
                AgentName = "Agent " + Guid.NewGuid()
            });
            Agent agent = new Agent()
            {
                Id = newAgent.AgentId
            };

            return(agent);
        }
コード例 #5
0
ファイル: Program.ashx.cs プロジェクト: jameszelada/WV-TRUNK
        public override string AddRecord(HttpContext context)
        {
            JsonResponse         response = new JsonResponse();
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            string   codigo = "", proyectoDescripcion = "", estado = "";
            int      ID_Proyecto, ID_Comunidad, ID_TipoPrograma;
            DateTime FechaInicio, FechaFinal;

            codigo = context.Request.Params["Codigo"];
            proyectoDescripcion = context.Request.Params["ProgramaDescripcion"];
            estado          = context.Request.Params["Estado"];
            ID_TipoPrograma = Int32.Parse(context.Request.Params["ID_TipoPrograma"]);
            ID_Comunidad    = Int32.Parse(context.Request.Params["ID_Comunidad"]);
            ID_Proyecto     = Int32.Parse(context.Request.Params["ID_Proyecto"]);

            var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            FechaInicio = epoch.AddMilliseconds(Convert.ToInt64(context.Request.Params["FechaInicio"]));
            FechaFinal  = epoch.AddMilliseconds(Convert.ToInt64(context.Request.Params["FechaFinal"]));

            try
            {
                Programa programa = new Programa();
                programa.ID_Comunidad        = ID_Comunidad;
                programa.ID_Proyecto         = ID_Proyecto;
                programa.ID_TipoPrograma     = ID_TipoPrograma;
                programa.Codigo              = codigo;
                programa.ProgramaDescripcion = proyectoDescripcion;
                programa.Estado              = estado;
                programa.FechaFinal          = FechaFinal;
                programa.FechaInicio         = FechaInicio;
                programa.CreadoPor           = SystemUsername;


                _programa.Add(programa);
                _context.SaveChanges();

                response.IsSucess     = true;
                response.ResponseData = string.Empty;
                response.Message      = "Registro Creado Satisfactoriamente";
                response.CallBack     = string.Empty;
            }
            catch (Exception ex)
            {
                response.Message  = ex.Message;
                response.IsSucess = false;
            }

            return(serializer.Serialize(response));
        }
コード例 #6
0
 /// <summary>
 /// This method used for insert user access details in User Access Detail Table. -An
 /// </summary>
 /// <param name="userAccessDetail">This object contain formId and Role Id,Is Active,Created DateTime</param>
 /// <returns>return primary key</returns>
 public int AddUserAccessDetail(UserAccessDetail userAccessDetail)
 {
     try
     {
         _userAccessDetailContext.Add(userAccessDetail);
         _userAccessDetailContext.SaveChanges();
         return(userAccessDetail.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #7
0
        public int AddNewPOSLoginSession(POSLoginSession posLoginSession)
        {
            var pos = new POSLoginSession
            {
                CreatedDateTime = DateTime.UtcNow,
                LoginDateTime   = DateTime.UtcNow,
                LogoutDateTime  = null,
                UserId          = posLoginSession.UserId
            };

            _posLoginSession.Add(pos);
            _posLoginSession.SaveChanges();
            return(pos.Id);
        }
コード例 #8
0
 public int Add(Transaction entity)
 {
     if (entity == null)
     {
         throw new ArgumentException("parameter cannot be null");
     }
     if (entity.TransactionMethod != "Debit/Credit Card")
     {
         entity.Cardnumber = null;
         entity.CVV        = 0;
     }
     return(_repo.Add(entity));
     //_repo.SaveChanges();
 }
コード例 #9
0
        public IActionResult Post([FromBody] User user)
        {
            if (user == null)
            {
                return(BadRequest("USer data is null."));
            }

            _dataRepository.Add(user);
            _dataRepository.Save();
            return(CreatedAtRoute(
                       "GetUserById",
                       new { user.Id },
                       user));
        }
コード例 #10
0
        public IActionResult Post(Product product)
        {
            if (product == null)
            {
                return(BadRequest("Product is null."));
            }


            _dataRepository.Add(product);
            return(CreatedAtRoute(
                       "Get",
                       new { Id = product.ProductID },
                       product));
        }
コード例 #11
0
        public async Task <IActionResult> AddPhotoForProduct(int userid, int productid, [FromForm] PhotoForCreationDto photoForCreationDto)
        {
            if (userid != int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }

            var productFromRepo = await _repo.GetProduct(productid);

            var file = photoForCreationDto.File;

            var uploadResult = new ImageUploadResult();

            if (file.Length > 0)
            {
                using (var stream = file.OpenReadStream())
                {
                    var uplaodParams = new ImageUploadParams()
                    {
                        File           = new FileDescription(file.FileName, stream),
                        Transformation = new Transformation().Width(300).Height(300).Crop("fill").Gravity("face")
                    };

                    uploadResult = _Cloudinary.Upload(uplaodParams);
                }
            }

            photoForCreationDto.Url      = uploadResult.Uri.ToString();
            photoForCreationDto.PublicId = uploadResult.PublicId;

            var photo = _mapper.Map <Photo>(photoForCreationDto);

            if (!productFromRepo.Photos.Any(x => x.IsMain))
            {
                photo.IsMain = true;
            }

            _repo.Add <Photo>(photo);

            productFromRepo.Photos.Add(photo);

            if (await _repo.SaveAll())
            {
                var photoForReturnDto = _mapper.Map <PhotoForReturnDto>(photo);
                return(Ok(photoForReturnDto));
                //return CreatedAtRoute("GetPhoto", new { userid = userid, id = photo.Id }, photoForReturnDto);
            }

            return(BadRequest("Could not add the photo"));
        }
コード例 #12
0
 /// <summary>
 /// Method to add payload to database
 /// </summary>
 /// <param name="payLoad"></param>
 /// <returns></returns>
 public MerchantService.DomainModel.Models.PayLoad AddPayLoad(MerchantService.DomainModel.Models.PayLoad payLoad)
 {
     try
     {
         _payLoadContext.Add(payLoad);
         _payLoadContext.SaveChanges();
         return(payLoad);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #13
0
        public IActionResult Post([FromBody] User user)
        {
            var Users = _dataRepository.GetAll();
            var email = Users.FirstOrDefault(e => e.Email == user.Email);


            if (email != null)
            {
                return(BadRequest("Email Already in use."));
            }

            _dataRepository.Add(user);
            return(Ok(user));
        }
コード例 #14
0
        public IActionResult Post([FromBody] Farmer farmer)
        {
            Farmer farmerTOLogin = _datarepository.Get(farmer.Email);

            if (farmerTOLogin == null)
            {
                _datarepository.Add(farmer);
                return(new OkResult());
            }
            else
            {
                return(new ConflictResult());
            }
        }
コード例 #15
0
        public IActionResult Post([FromBody] Admin admin)
        {
            Admin adminTOReg = _dataRepository.Get(admin.Email);

            if (adminTOReg == null)
            {
                _dataRepository.Add(admin);
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #16
0
        public async Task <IActionResult> PostCliente([FromBody] Cliente cliente)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            cliente.CreateAt = DateTime.Now.Date;

            _repo.Add(cliente);
            var save = await _repo.SaveAsync(cliente);

            return(CreatedAtAction("GetCliente", new { id = cliente.Id }, cliente));
        }
コード例 #17
0
        public IActionResult Post([FromBody] SettingsCategory settingCategory)
        {
            if (settingCategory == null)
            {
                return(BadRequest("Category is null."));
            }

            _dataRepository.Add(settingCategory);
            _dataRepository.Save();
            return(CreatedAtRoute(
                       "GetSettingsCategoryById",
                       new { settingCategory.Id },
                       settingCategory));
        }
コード例 #18
0
 /// <summary>
 /// This method used for insert in to incident report and return primary key. -An
 /// </summary>
 /// <param name="incidentReport">incident report contain OperationTypeId,AmountLimit,OperationCounter,Comment,
 /// StatusId,StartDateTime,EndDateTime,DurationTypeId,CompanyId</param>
 /// <returns></returns>
 public int AddIncidentReport(IncidentReport incidentReport)
 {
     try
     {
         _incidentReportContext.Add(incidentReport);
         _incidentReportContext.SaveChanges();
         return(incidentReport.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #19
0
 /// <summary>
 /// This method used for insert parent Recored and return Primary key. -An
 /// </summary>
 /// <param name="parentRecord">TypeId,StatusId,BranchId,InitiatorId,InitiationComment,ModifiedUserId,ModifiedUserId,ModificationDate</param>
 /// <returns></returns>
 public int AddParentRecords(ParentRecord parentRecord)
 {
     try
     {
         _iParentRecordContext.Add(parentRecord);
         _iParentRecordContext.SaveChanges();
         return(parentRecord.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #20
0
        public override Task <AddUserResposne> AddUser(AddUserMessage request, ServerCallContext context)
        {
            Guid id = Guid.NewGuid();

            _repository.Add(new UserEntry
            {
                Id       = id,
                Username = request.Username
            });

            return(Task.FromResult(new AddUserResposne {
                Id = id.ToString()
            }));
        }
コード例 #21
0
ファイル: NewsController.cs プロジェクト: azsatti/NewsSite
        public async Task <IActionResult> Create([FromBody] NewsArticle newsArticle)
        {
            if (newsArticle == null)
            {
                _logger.LogError("Bad request");
                return(BadRequest());
            }

            await _repo.Add(newsArticle);

            return(CreatedAtRoute("GetNewsById",
                                  new { id = newsArticle.Id },
                                  newsArticle));
        }
コード例 #22
0
        public async Task <IActionResult> Post([FromBody] string value)
        {
            if (value == null)
            {
                return(BadRequest("Value is null."));
            }
            var animal = JsonConvert.DeserializeObject <Animal>(value);
            await _dataRepository.Add(animal);

            return(CreatedAtRoute(
                       "Get",
                       new { Id = animal.AnimalId },
                       animal));
        }
コード例 #23
0
        public void CommitChanges()
        {
            _repository.Add(new Description
            {
                Template = nameof(CommitChanges)
            });

            _sut.Commit();

            var entity = _repository.Get(x => x.Template == nameof(CommitChanges));

            entity.Should().BeAssignableTo <Description>()
            .And.NotBeNull();
        }
コード例 #24
0
 /// <summary>
 /// This method used for add destruction item and return primary key. -An
 /// </summary>
 /// <param name="itemDestructionDetail"></param>
 /// <returns></returns>
 public int AddDestructionItem(ItemDestructionDetail itemDestructionDetail)
 {
     try
     {
         _iItemDestructionDetailContext.Add(itemDestructionDetail);
         _iItemDestructionDetailContext.SaveChanges();
         return(itemDestructionDetail.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #25
0
        public IActionResult Post([FromBody] NeuFinesse.Data.Model.Item item)
        {
            if (item == null)
            {
                return(BadRequest("Item is null."));
            }

            _dataRepository.Add(item);
            return(Ok("Item added successfully"));
            //return CreatedAtRoute(
            //      "Get",
            //      new { Id = item.ItemId },
            //      item);
        }
コード例 #26
0
        public IActionResult Post([FromBody] Album album)
        {
            if (album is null)
            {
                return(BadRequest("Album is null."));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            _dataRepository.Add(album);
            return(CreatedAtRoute("GetAlbum", new { Id = album.Id }, null));
        }
コード例 #27
0
 /// <summary>
 /// This method is used for insert data in posIncidentReport.
 /// </summary>
 /// <param name="posIncidentReport"></param>
 /// <returns></returns>
 public DomainModel.Models.IncidentReport.PosIncidentReport InsertPosIncidentReport(DomainModel.Models.IncidentReport.PosIncidentReport posIncidentReport)
 {
     try
     {
         posIncidentReport.CreatedDateTime = DateTime.UtcNow;
         _posIncidentReportDataRepository.Add(posIncidentReport);
         _posIncidentReportDataRepository.SaveChanges();
         return(posIncidentReport);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }
コード例 #28
0
        /// <summary>
        /// This method used for added consumer app and return consumerApps Id. -An
        /// </summary>
        /// <param name="consumerApp">App details as object</param>
        /// <returns>App details after saving changes as object</returns>
        public async Task <IdentityServer4.Models.Client> AddConsumerAppsAsync(ConsumerApps consumerApp)
        {
            if (await _clientDataRepository.FirstOrDefaultAsync(x => x.ClientId == consumerApp.AuthId) == null)
            {
                var clientApp = ReturnIdentityServerClientFromConsumerApp(consumerApp, ReturnListOfScopesInStringFromEnumAllowedScope(consumerApp.Scopes));
                _clientDataRepository.Add(clientApp.ToEntity());
                await _clientDataRepository.SaveChangesAsync();

                return(clientApp);
            }
            else
            {
                throw new ConsumerAppNameIsAlreadyExists();
            }
        }
コード例 #29
0
        public async Task <IActionResult> PostCustomer([FromBody] Customer customer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _repo.Add(customer);
            var save = await _repo.SaveAsync(customer);

            // _context.Customer.Add(customer);
            // await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCustomer", new { id = customer.Id }, customer));
        }
コード例 #30
0
 /// <summary>
 /// This method used for insert into POSSession table and return primary key. -An
 /// </summary>
 /// <param name="posSession">POSsession contains  POSLoginSessionId,MismatchResolveTypeID,StartDate,EndDate,IsMatched,MismatchedValue,
 /// Cash,DebitCard,CreditCard,Coupon,CreditAccount,ReturnedBill,ActualCash,ActualDebitCard,ActualCreditCard,ActualCoupon,ActualCreditAccount</param>
 /// <returns></returns>
 public int AddNewPOSSession(POSSession posSession)
 {
     try
     {
         posSession.CreatedDateTime = DateTime.UtcNow;
         _posSessionsContext.Add(posSession);
         _posSessionsContext.SaveChanges();
         return(posSession.Id);
     }
     catch (Exception ex)
     {
         _errorLog.LogException(ex);
         throw;
     }
 }